<?php
my_component_load('testing' , false);
my_component_load('paging' , false);
my_component_load('data_setting', false);
my_component_load('keluarga_jabatan');
$task = isset($_GET['task']) ? $_GET['task'] : ""; 
$id = isset( $_GET['id'] ) ? $_GET['id']:  0;
$kid = isset( $_GET['kid'] ) ? $_GET['kid']:  0;
$modulname = "Admin _BN_ Konfigurasi Data";

if($_SERVER['REQUEST_METHOD'] == "POST" ):
	$validatepost = form_keluarga_jabatan_validate($id);
	switch($task){
		case   "create" :	
			if($validatepost)
			{
				$errors = message_multi_error($validatepost);
				$content = $errors; 
				$content .= form_keluarga_jabatan_create( $id );
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_submit_data_keluarga_jabatan($id);
				my_direct( 'index.php?com='.$_GET['com'].'&task=detail_entry_karyawan&id='.$id );
			}
		break;
		case   "edit" :
			form_edit_data_keluarga_jabatan_submit($id);
			my_direct( 'index.php?com=karyawan&task=detail&id='.$id );
		break;
		case   "edit_page" :
			if($validatepost)
			{
				$errors = message_multi_error($validatepost);
				$content = $errors; 
				$content .= form_keluarga_jabatan_create( $id );
				generate_my_web($content,"","plain.php");
				exit; 
			}else{
				form_keluarga_jabatan_submit($id);
				$content="Updated";
				$pagename = "";
				generate_my_web($content, $pagename ,'plain.php' );
				exit;
			}
		break;
	}

else: 	
	if($task == "edit_page"){ 
		$content  = form_keluarga_jabatan_create( $id );
		generate_my_web($content,"","plain.php");
		exit;		
	}elseif($task == 'edit_popup'){	
		$title= ($id > '0' ) ?  "Perubahan Data" : "Tambah Data";
		facebox_page('index.php?com=keluarga_jabatan&task=edit_page&id='.$id  , $title , 180	); 
	}elseif($task == 'delete'){	
		delete_keluarga_jabatan($id);
		my_direct($_SERVER['HTTP_REFERER']);
	}else{
		$pagename = "Daftar Job Family";
		load_facebox_script();
		$view = list_keluarga_jabatan();
		$href = 'index.php?com=keluarga_jabatan&task=edit_popup' ;	
	}
endif;  
$content = spliter_browser( $view , $pagename ,$href);
generate_my_web($content, $modulname." _BN_ Job Family" );

?>